<template>
  <div>
    <Header></Header>
    <!--左侧菜单-->
    <div class="w" >
        <ul class="keywords-list" >
          <li class="keywords-item" v-for="item in categoryList">
            <router-link class="link" :to="{'name':'itemList','query':{'categoryId':item.id}}">{{item.name}}</router-link>
          </li>
        </ul>
      <!--轮播图-->
      <swiper options="swiperOption" ref="mySwiper" class="banner-con">
        <!-- slides -->
        <swiper-slide><img class="banner-img" src="../assets/banner1.jpg"/> </swiper-slide>
        <swiper-slide><img class="banner-img" src="../assets/banner2.jpg"/> </swiper-slide>
        <swiper-slide><img class="banner-img" src="../assets/banner3.jpg"/> </swiper-slide>
        <swiper-slide><img class="banner-img" src="../assets/banner4.jpg"/> </swiper-slide>
        <swiper-slide><img class="banner-img" src="../assets/banner5.jpg"/> </swiper-slide>
        <!-- 分页器 -->
        <div class="swiper-pagination"  slot="pagination"></div>
        <!-- 导航按钮 -->
        <div class="swiper-button-prev" slot="button-prev"></div>
        <div class="swiper-button-next" slot="button-next"></div>
      </swiper>
    </div>
    <!--楼层展示商品-->
    <div class="w">
      <div class="floor-wrap">
        <h3 class="floor-title">家用电器</h3>
        <ul class="floor-list">
          <li class="floor-item">
            <router-link class="link" :to="{'name':'itemList','query':{'categoryId':100011}}">
              <span class="floor-text">双开门冰箱</span> <img class="floor-img" src="../assets/floor1-1.jpg" alt="双开门冰箱">
            </router-link>
          </li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100012}}">
            <span class="floor-text">电视</span> <img class="floor-img" src="../assets/floor1-2.jpg" alt="电视">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100014}}">
            <span class="floor-text">洗衣机</span> <img class="floor-img" src="../assets/floor1-3.jpg" alt="洗衣机">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100015}}">
            <span class="floor-text">空调</span> <img class="floor-img" src="../assets/floor1-4.jpg" alt="空调">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100016}}">
            <span class="floor-text">热水器</span> <img class="floor-img" src="../assets/floor1-5.jpg" alt="热水器">
          </router-link></li>
        </ul>
      </div>
      <div class="floor-wrap">
        <h1 class="floor-title">数码3C</h1>
        <ul class="floor-list">
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100017}}">
            <span class="floor-text">笔记本电脑</span> <img class="floor-img" src="../assets/floor2-1.jpg" alt="笔记本电脑">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100018}}">
            <span class="floor-text">手机</span> <img class="floor-img" src="../assets/floor2-2.jpg" alt="手机">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100019}}">
            <span class="floor-text">平板电脑</span> <img class="floor-img" src="../assets/floor2-3.jpg" alt="平板电脑">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100020}}">
            <span class="floor-text">数码相机</span> <img class="floor-img" src="../assets/floor2-4.jpg" alt="数码相机">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100021}}">
            <span class="floor-text">3C配件</span> <img class="floor-img" src="../assets/floor2-5.jpg" alt="3C配件">
          </router-link></li>
        </ul>
      </div>
      <div class="floor-wrap">
        <h1 class="floor-title">服装箱包</h1>
        <ul class="floor-list">
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100022}}">
            <span class="floor-text">女装</span> <img class="floor-img" src="../assets/floor3-1.jpg" alt="女装">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100023}}">
            <span class="floor-text">帽子专区</span> <img class="floor-img" src="../assets/floor3-2.jpg" alt="帽子专区">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100024}}">
            <span class="floor-text">旅行箱</span> <img class="floor-img" src="../assets/floor3-3.jpg" alt="旅行箱">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100025}}">
            <span class="floor-text">手提包</span> <img class="floor-img" src="../assets/floor3-4.jpg" alt="手提包">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100026}}">
            <span class="floor-text">保暖内衣</span> <img class="floor-img" src="../assets/floor3-5.jpg" alt="保暖内衣">
          </router-link></li>
        </ul>
      </div>
      <div class="floor-wrap">
        <h1 class="floor-title">食品生鲜</h1>
        <ul class="floor-list">
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100027}}">
            <span class="floor-text">最爱零食</span> <img class="floor-img" src="../assets/floor4-1.jpg" alt="最爱零食">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100028}}">
            <span class="floor-text">生鲜</span> <img class="floor-img" src="../assets/floor4-2.jpg" alt="生鲜">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100029}}">
            <span class="floor-text">半成品菜</span> <img class="floor-img" src="../assets/floor4-3.jpg" alt="半成品菜">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100030}}">
            <span class="floor-text">速冻专区</span> <img class="floor-img" src="../assets/floor4-4.jpg" alt="速冻专区">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100031}}">
            <span class="floor-text">进口牛奶</span> <img class="floor-img" src="../assets/floor4-5.jpg" alt="进口牛奶">
          </router-link></li>
        </ul>
      </div>
      <div class="floor-wrap">
        <h1 class="floor-title">酒水饮料</h1>
        <ul class="floor-list">
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100032}}">
            <span class="floor-text">白酒</span> <img class="floor-img" src="../assets/floor5-1.jpg" alt="白酒">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100033}}">
            <span class="floor-text">红酒</span> <img class="floor-img" src="../assets/floor5-2.jpg" alt="红酒">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100034}}">
            <span class="floor-text">饮料</span> <img class="floor-img" src="../assets/floor5-3.jpg" alt="饮料">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100035}}">
            <span class="floor-text">调制鸡尾酒</span> <img class="floor-img" src="../assets/floor5-4.jpg" alt="调制鸡尾酒">
          </router-link></li>
          <li class="floor-item"><router-link class="link" :to="{'name':'itemList','query':{'categoryId':100036}}">
            <span class="floor-text">进口洋酒</span> <img class="floor-img" src="../assets/floor5-5.jpg" alt="进口洋酒">
          </router-link></li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
  import Nav from '../components/Nav'
  import Header from '../components/Header'
  import Vue from 'vue'
  import VueAwesomeSwiper from 'vue-awesome-swiper'
  import '../../static/css/swiper.css';
  Vue.use(VueAwesomeSwiper, {
    //左右换图
    direction: 'horizontal',
    //最后一张可以切换回第一张
    loop:true,
    //分页器
    pagination :{
      el: '.swiper-pagination',
      clickable :true,
    },
    //自动循环
    autoplay: true,
    //前进后退按钮
    navigation: {
      nextEl: '.swiper-button-next',
      prevEl: '.swiper-button-prev',
    },
  })
  export default {
    name: 'Home',
    data(){
      return {
        msg: 'hello',
        categoryList: []
      }
    },
    created(){
      //当home.vue创建时，自动回调的方法，（钩子函数）
      //请求服务器端数据
      this.getCategoryList()
    },
    components:{
      Nav,Header
    },
    methods:{
      //定义方法，访问服务器接口，查询所有分类信息
      //http://yfb.neuedu.com:8812/manage/category/add_category.do
      getCategoryList:function () {
        //使用Axios模块提供的API访问服务器端
        //方法回调1
        this.axios.get('/manage/category/get_category.do',{params:{'categoryId':0}})
          .then((response)=>{
            console.log(response.data.data);
            this.categoryList = response.data.data;
          });
      }
    }
  }
</script>

<style scoped >
  /* keywords-list */
  .keywords-list {
    float: left;
    width: 240px;
    height: 350px;
    padding: 10px 0;
    margin-right: 10px;
    background: #fefefe;
    color: #fff;
  }

  .keywords-list .keywords-item {
    padding-left: 10px;
    height: 35px;
    line-height: 35px;
    font-size: 14px;
  }

  .keywords-list .keywords-item:hover {
    background: #9999;
  }

  .keywords-list .keywords-item .link {
    margin-right: 1px;
    color: #626262;
  }

  .keywords-list .keywords-item .link:hover {
    color: #FF8800;
  }
  /* banner-con */
  .banner-con {
    width: 830px;
    float: left;
    height: 370px;
    background: #eee;
  }
  .banner-con .loading {
    margin-top: 150px;
  }

  .banner-con .banner-img {
    width: 100%;
    height: 370px;
  }

  /* banner的前一张和后一张按钮 */
  .banner-con .banner-arrow {
    position: absolute;
    top: 160px;
    width: 30px;
    height: 50px;
    line-height: 50px;
    text-align: center;
    font-size: 30px;
    color: #fff;
    background: #ccc;
    background: rgba(0, 0, 0, .2);
    cursor: pointer;
  }
  .banner-con .banner-arrow:hover {
    background: #aaa;
    background: rgba(0, 0, 0, .5);
  }
  .banner-con .banner-arrow.prev {
    left: 0;
  }

  .banner-con .banner-arrow.next {
    right: 0;
  }

  /* floor */

  .floor-wrap .floor-title {
    position: relative;
    height: 50px;
    line-height: 50px;
    color: #d58717;
    font-weight: normal;
    font-size: 28px;
    font-family: 'fzzzh', sans-serif;
    text-align: center;
    padding: 0 25px;
    color: #222;
    border-bottom: 1px solid #000000;
  }

  .floor-title::before, .floor-title::after {
    content: '';
    position: absolute;
    width: 50px;
    height: 3px;
    display: block;
    background: #222;
    top: 25px;
  }

  .floor-wrap .floor-title::before {
    left: 410px;
  }

  .floor-wrap .floor-title::after {
    right: 410px;
  }

  /* 更改各楼层标题颜色 */
  .floor-wrap:nth-child(2) .floor-title {
    color: #3b838c;
    border-bottom: 1px solid #3b838c;
  }

  .floor-wrap:nth-child(3) .floor-title {
    color: #a93931;
    border-bottom: 1px solid #a93931;
  }

  .floor-wrap:nth-child(4) .floor-title {
    color: #488bad;
    border-bottom: 1px solid #488bad;
  }

  .floor-wrap:nth-child(5) .floor-title {
    color: #642663;
    border-bottom: 1px solid #642663;
  }

  .floor-wrap .floor-list {
    margin-right: -20px;
    overflow: hidden;
  }

  .floor-wrap .floor-list .floor-item {
    position: relative;
    width: 200px;
    height: 220px;
    margin: 15px 20px 15px 0;
    float: left;
    cursor: pointer;
    background: #fff;
  }

  .floor-wrap .floor-list .floor-item:hover {
    box-shadow: 1px 1px 7px #ddd;
  }

  .floor-wrap .floor-list .floor-item .floor-text {
    position: absolute;
    top: 12px;
    left: 20px;
    font-size: 16px;
    color: #555;
  }

  .floor-wrap .floor-list .floor-item .floor-img {
    position: absolute;
    right: 15px;
    bottom: 10px;
    width: 80%;
    height: 75%;
    border: none;
  }

  /* banner */
  .banner {
    position: relative;
    overflow: auto;
  }

  .banner li {
    list-style: none;
  }

  .banner ul li {
    float: left;
  }

  /* banner的前一张和后一张按钮 */
  .banner .dots {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 20px;
    text-align: center;
  }

  .banner .dots li {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin: 0 4px;
    text-indent: -999em;
    border: 2px solid #fff;
    border-radius: 6px;
    cursor: pointer;
    opacity: .4;
    -webkit-transition: background .5s, opacity .5s;
    -moz-transition: background .5s, opacity .5s;
    transition: background .5s, opacity .5s;
  }

  .banner .dots li.active {
    background: #fff;
    opacity: 1;
  }

  /* 瀵艰埅涓讳綋 */
  .nav-side {
    float: left;
    width: 130px;
    min-height: 100px;
  }

  .nav-side .nav-item {
    line-height: 25px;
    font-size: 13px;
  }

  .nav-side .nav-item .link {
    color: #888;
  }

  .nav-side .nav-item.active .link {
    color: #FF8800;
  }

  .content.with-nav {
    float: left;
    width: 950px;
  }
</style>
